#region Using
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
#endregion Using

namespace PhotoGallery.Core.Business
{
	public class RoleOperationKey
	{
		#region Field and Properties

		private int operationId = 0;
		/// <summary>
		/// 
		/// </summary>
		public int OperationId
		{
			get { return operationId; }
			set
			{
				if (value != operationId)
				{
					operationId = value;
				}
			}
		}

		private int roleId = 0;
		/// <summary>
		/// 
		/// </summary>
		public int RoleId
		{
			get { return roleId; }
			set
			{
				if (value != roleId)
				{
					roleId = value;
				}
			}
		}


#endregion

		#region Constructors

		public RoleOperationKey()
		{
		}

		public RoleOperationKey(int operationId, int roleId)
		{
			this.OperationId = operationId;
			this.RoleId = roleId;
		}

		#endregion

		#region Overrides

		public override int GetHashCode()
		{
			return this.OperationId.GetHashCode() + this.RoleId.GetHashCode();
		}

		public override bool Equals(object obj)
		{
			if (obj == null){ return false; }
			if (this.GetType() != obj.GetType()) { return false; }

			return this.OperationId == ((RoleOperationKey)obj).OperationId && this.RoleId == ((RoleOperationKey)obj).RoleId;
		}

		public static bool operator ==(RoleOperationKey left, RoleOperationKey right)
		{
			if (Object.ReferenceEquals(left, right)) { return true; }
			if ((object)left == null || (object)right == null) { return false; }

			return left.OperationId == right.OperationId && left.RoleId == right.RoleId;
		}

		public static bool operator !=(RoleOperationKey left, RoleOperationKey right)
		{
			return !(left == right);
		}

		#endregion
	}

	public class RoleOperation : Business.BusinessBase<RoleOperation, RoleOperationKey>
	{
		#region Fields and Properties

		private DateTime addDate = DateTime.MinValue;
		/// <summary>
		/// 
		/// </summary>
		public DateTime AddDate
		{
			get { return addDate; }
			set
			{
				if (value != addDate)
				{
					MarkChanged("AddDate");
					addDate = value;
				}
			}
		}

		private int status = 0;
		/// <summary>
		/// 
		/// </summary>
		public int Status
		{
			get { return status; }
			set
			{
				if (value != status)
				{
					MarkChanged("Status");
					status = value;
				}
			}
		}

		#endregion Fields and Properties

		#region Constructors

		public RoleOperation()
		{
		}

		#endregion Constructors

		#region Base overrides

		protected override void ValidationRules()
		{
		}

		protected override RoleOperation DataSelect(RoleOperationKey id)
		{
			return Services.DALService.RoleOperationService.Select(id);
		}

		protected override void DataUpdate()
		{
			Services.DALService.RoleOperationService.Update(this);
		}

		protected override void DataInsert()
		{
			Services.DALService.RoleOperationService.Insert(this);
		}

		protected override void DataDelete()
		{
			Services.DALService.RoleOperationService.Delete(this);
		}

		#endregion Base overrides
	}
}
